package beautiful.butterfly.server.httpserver.mvc.http;


import beautiful.butterfly.server.httpserver.mvc.render.Render;
import beautiful.butterfly.server.httpserver.mvc.wrapper.OutputStreamWrapper;
import io.netty.buffer.ByteBuf;
import io.netty.handler.codec.http.FullHttpResponse;

import java.io.File;
import java.io.IOException;
import java.util.Map;


public interface Response {


    int getStatusCode();


    Response setStatus(int status);

    String getContentType();

    Response setContentType(CharSequence contentType);

    Map<String, String> headerMap();


    Response setHeader(CharSequence name, CharSequence value);


    Map<String, String> cookieMap();


    Response cookie(Cookies Cookies);

    Response cookie(String name, String value);


    Response cookie(String name, String value, int maxAge);


    Response cookie(String name, String value, int maxAge, boolean secured);


    Response cookie(String path, String name, String value, int maxAge, boolean secured);


    Response removeCookie(String name);


    /**
     * download some file to client
     */
    void download(String fileName, File file) throws Exception;

    /**
     * create temp file outputStream
     */
    OutputStreamWrapper outputStream() throws IOException;


    void render(Render render);

    /**
     * Redirect to newUri
     */
    void redirect(String newUri);

    /**
     * Judge whether the current getResponse has been submitted to the client
     */
    boolean isCommit();


    void send(FullHttpResponse fullHttpResponse);

    public void body(ByteBuf byteBuf);

    public void html(String html);
}
